package xyz.yolin.test;

public class fib {
    public static void main(String[] args) {
        System.out.println(fib1(6));
        System.out.println(fib2(6));
    }
    public static int fib1(int i){
        if (i<=1){
            return i;
        }
        return fib1(i-1)+fib1(i-2);
    }

    public static int fib2(int n){
        if (n==0){
            return 0;
        }
        int sum=1;
        int one=0;
        for (int i=1;i<n;i++){
            sum=sum+one;
            one=sum-one;
        }
        return sum;
    }
}
